const contextPath = process.env.NODE_ENV === 'production' ? `/datav` : '';

const h5ContextPath = process.env.NODE_ENV === 'production' ? '/service' : '/server';

export const url = {
  // 登入认证接口
  authLoginUrl: `${contextPath}/api/v3/login`,
  // 获取当前登录用户信息
  currentUserUrl: `${contextPath}/api/v3/user/current`,
  // 用户管理-获取表格用户列表
  queryUsersUrl: `${contextPath}/api/v3/user/list`,
  createUserUrl: `${contextPath}/api/v3/user/createUser`,
  userIsExistUrl: `${contextPath}/api/v3/user/isExist`,
  // 搜索通行证
  searchUsersUrl: `${contextPath}/api/v3/user/search`,
  //设置用户项目权限
  updateUserProjectUrl: `${contextPath}/api/v3/user/update`,
  //获取项目成员列表
  getAllUserByProjectUrl: `${contextPath}/api/v3/role/getUserList`,
  //看板列表
  getDashboardListUrl: `${contextPath}/api/v3/role/getDashboardList`,
  //删除角色
  deleteRoleUrl:(roleId: any) =>`${contextPath}/api/v3/role/delete/${roleId}`,
  //新增绑定用户
  addUserRoleUrl: `${contextPath}/api/v3/role/addUserRole`,
  //保存角色看板
  updateRoleDashboardUrl: `${contextPath}/api/v3/role/updateRoleDashboard`,
  //删除绑定用户
  deleteRoleUserUrl: `${contextPath}/api/v3/role/deleteRoleUser`,
  // 当前用户所有项目权限
  userPriUrl: `${contextPath}/api/v3/user/jurisdiction`,
  //编辑单人项目权限
  editUserPri:(id: any)=>`${contextPath}/api/v3/user/jurisdiction/${id}`,
  // 用户管理-身份分配-身份列表
  queryIdentitysUrl: `${contextPath}/api/v3/identity/list`,
  // 用户管理-身份分配-保存
  changeUserIdentity: `${contextPath}/api/v3/identity/changeUserIdentity`,
  // 用户管理-权限管理-分配角色列表
  queryRolesUrl: `${contextPath}/api/v3/role/list`,
  // 用户管理-权限管理-项目权限列表
  queryProjectsUrl: `${contextPath}/api/v3/project/list`,
  // 用户管理-权限管理-分配角色-保存
  changeUserRole: `${contextPath}/api/v3/role/changeUserRole`,
  // 用户管理-权限管理-项目权限-保存
  changeUserDashboard: `${contextPath}/api/v3/dashboard/changeUserDashboard`,
  // 角色管理-权限管理-项目列表
  queryDashboardPortalProjectsList: `${contextPath}/api/v3/dashboard/list_portal_with_project`,
  // 角色管理-权限管理-看板列表
  queryPortalList: `${contextPath}/api/v3/dashboard/list_with_portal`,
  // 角色管理-创建角色
  createRoleUrl: `${contextPath}/api/v3/role/create`,
  // 角色管理-权限管理-保存
  changeRoleDashboard: `${contextPath}/api/v3/dashboard/changeRoleDashboard`,
  //查询看板
  queryDashboardWithProjectsUrl: `${contextPath}/api/v3/dashboard/list_with_project`,
  //查询指标
  queryWidgetWithDashboardsUrl: `${contextPath}/api/v3/widget/list_with_dashboard`,
  //通过项目Id查询指标
  queryWidgetByProjectIdUrl: (params: any) => `${contextPath}/api/v3/widget/by_project/${params.projectId}`,
  // 看板管理-创建分组
  createGroup: `${contextPath}/api/v3/dashboard/createGroup`,
  // 看板管理-分组重命名
  renameGroup: (params: any) =>
    `${contextPath}/api/v3/dashboard/renameGroup/${params.id}?name=${params.name}`,
  // 看板管理-删除分组
  removeGroup: (params: any) =>
    `${contextPath}/api/v3/dashboard/removeGroup/${params.id}`,
  // 看板管理-添加指标
  addWidgetsUrl: (params: any) =>
    `${contextPath}/api/v3/dashboard/${params.dashboardId}/widgets`,
  // 看板管理-删除指标
  deleteWidgets: (params: any) =>
    `${contextPath}/api/v3/dashboard/remove/dashboards/widgets/${params.relationId}`,
  // 看板分组-更新指标
  updateGroup: (params: any) =>
    `${contextPath}/api/v3/dashboard/changeGroup/${params.id}/widgets`,
  //
  renameDashboardUrl: (params: any) =>
    `${contextPath}/api/v3/dashboard/renameDashboard/${params.id}?name=${params.name}`,

  // 自助查询-看板中心-看板列表
  queryPanelsList: `${h5ContextPath}/api/v3/h5/panels`,
  //看板中心-获取指标列表
  queryDashboardsUrl: (params: any) =>
    `${h5ContextPath}/api/v3/dashboardPortals/${params.portalId}/dashboards/${params.dashboardId}`,
  //看板中心-获取指标图表数据所需参数
  queryWidgetParamsUrl: (params: any) => `${h5ContextPath}/api/v3/h5/widgets/${params.id}`,
  // 看板中心-获取指标图表数据
  queryWidgetDataUrl: (params: any) => `${h5ContextPath}/api/v3/views/${params.id}/getdata`,
  // 指标订阅
  subscribeWidgetUrl: `${h5ContextPath}/api/v3/h5/subscribe`,
  //取消订阅指标
  canelSubscribeWidgetUrl: `${h5ContextPath}/api/v3/h5/subscribe/canel`,
  //获取我的订阅列表
  querySubscribeWidgetsUrl: `${h5ContextPath}/api/v3/h5/subscribe/list`,
  //保存订阅列表排版
  savePositionUrl: `${h5ContextPath}/api/v3/h5/subscribe/position`,
  //获取所有指标列表
  queryWidgetsUrl: `${h5ContextPath}/api/v3/h5/widgets`,
  //存储感兴趣的指标
  saveWidgetRecordUrl: `${h5ContextPath}/api/v3/h5/saveWidgetsRecords`,
  //获取感兴趣的指标
  queryWidgetRecordsUrl: `${h5ContextPath}/api/v3/h5/getWidgetsRecords`,
  //获取所有指标筛选条件
  queryLevelsUrl: `${h5ContextPath}/api/v3/mdm/levels`,
  // 数据管理-查询表格数据
  queryRoleListUrl: `${contextPath}/api/v3/dataRole/list`,
  createRole: `${contextPath}/api/v3/dataRole/create`,
  // 数据表-获取权限范围内的所有视图
  querySheetList: `${contextPath}/api/v3/view/list`,
  // 根据项目ID获取数据表-获取权限范围内的所有视图
  querySheetListByProjectIdUrl: (projectId: number) => `${contextPath}/api/v3/view/list/${projectId}`,
  // 数据表-更新视图model
  saveModel: `${contextPath}/api/v3/view/set/model`,
  // 根据数据角色唯一no获取数据角色明细
  queryRoleDetailUrl: (params: any) =>
    `${contextPath}/api/v3/dataRole/detail/${params.no}`,

  queryRoleAllUrl: `${contextPath}/api/v3/dataRole/listWithDetail`,

  bindDataRole: `${contextPath}/api/v3/dataRole/user/bind`,

  queryUserRoleUrl: (params: any) =>
    `${contextPath}/api/v3/user/dataRole/${params.id}`,
  setGrobalFilterUrl: `${contextPath}/api/v3/project/grobalFilter/set`,
  queryGrobalFilterByUrl: (params: any) =>
    `${contextPath}/api/v3/project/grobalFilter/${params.projectId}`,
  queryDashboardOperation: (params: any) =>
    `${contextPath}/api/v3/dashboard/operation/${params.projectId}`,
  addFolderUrl: (params: any) =>
    `${contextPath}/api/v3/dashboard/addFolder/${params.projectId}`,
  getDistinctValueUrl: (viewId: any) =>
    `${h5ContextPath}/api/v3/views/${viewId}/getdistinctvalue`,
  updateFilterConfigUrl: () =>
    `${contextPath}/api/v3/dashboard/updateFilterConfig`,
  executesqlUrl: `${contextPath}/api/v3/view/executesql`,
};

export interface IExecutesqlParams {
  limit: number,
  sourceId: number,
  sql: string
}
